1. Technology Field
The present invention relates to a data management method and particularly to a management method for data written in a physical block of a rewritable non-volatile memory module and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Digital cameras, cells phones, and MP3 players have undergone rapid growth in recent years. Thus, consumer demand for storage media has also rapidly increased. Rewritable non-volatile memory is one of the most adaptable memories for battery-powered portable products such as laptop computers due to its characteristics such as data non-volatility, low power consumption, small volume, non-mechanical structure, and high read and write speed. A solid state drive (SSD) is a storage apparatus adopting flash memory as storage medium. Therefore, the flash memory industry has become a very important part of the electronic industry in recent years.
A memory sub-module of a flash memory module has a plurality of physical units. Each physical unit is formed from one or more physical blocks, and each physical block has a plurality of physical pages, wherein data must be written into a physical block according to the sequence of the physical pages in the physical block. Additionally, a physical page with data has to be erased before data is written into again. In particular, the smallest unit for erasing data is one physical block, and the smallest unit for programming (also referred to writing) data is one physical page. Therefore, in the management of the flash memory module, the physical units are grouped into a data area and a free area.
The physical units of the data area are used for storing data written by the host system. To be specific, a memory management circuit converts the logical access addresses accessed by the host system into logical pages of logical units, and maps the logical pages of the logical units to the physical pages of the physical units of the data area. Namely, in the management of the flash memory module, the physical units of the data area are regarded as used physical units (i.e. data from the host system is already stored). For example, the memory management circuit will use a logical unit-physical unit mapping table to record a mapping relationship between the logical units and the physical units of the data area, wherein the logical pages of the logical units are sequentially corresponding to the mapped physical pages of the physical units.
The physical units of the free area are used for substituting the physical units of the data area. Specifically, as described above, the written data of the physical blocks must be erased before it can write data again. Thus, the physical units of the free area are designed to write update data to substitute the physical units that map the logical units. Hence, the physical units in the free area are either blank or available units (i.e., no data is recorded in these units or data recorded in these units is marked as invalid data).
In other words, the physical pages of the physical units in the data area and the free area are alternatively used to map the logical pages of the logical units, to store data written by the host system. For example, the memory management circuit of a storage apparatus will get one or more physical units from the free area to be a substituted physical unit, and when the host system desires to write the update data into the logical access address corresponding to a logical page of a logical unit, the memory management circuit of the storage apparatus will write the update data in the physical page of the substituted physical unit.
In addition, the memory management circuit will mark the physical pages originally mapped to the logical pages written by the host system as invalid. In particular, if the amount of useful physical units in the free area is less than a preset threshold value, when executing writing commands, the memory management circuit must proceed with data merging, to avoid exhausting the physical units of the free area. Specifically, in the data merging process, the memory management circuit will get an empty physical unit from the free area, and copy valid data belonging to the same logical unit among the physical unit of the substituted physical unit and the data area to the gotten physical unit. From this, the substituted physical unit and the physical units of the data area stored the invalid data can be erased and associated to the free area.
With the progress of process of the flash memory, the capacity of each physical page in the physical blocks becomes larger. Take a conventional flash memory for example, the capacity of one of physical pages is 8 kilobytes (KB). However, the unit of the data written by the host system to the storage apparatus is usually 4 kilobytes, such that when the host system writes data of 4 kilobytes into a physical page of 8 kilobytes, the rest 4 kilobytes of the physical page are not used. Therefore, the capacity of the physical unit will be wasted.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.